package chess.client;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;

public class ChessSquare extends Composite {
	public final AbsolutePanel Square = new AbsolutePanel();
		
	public String PieceId = null;
	public Image Piece = null;
	public Integer row;
	public Integer col;
	
	public ChessSquare(Integer row, Integer col, String sPiece) {
		Square.setStyleName("chesssquarediv" + ((((row%2 + col%2)%2)==0) ? "white" : "black"));
				
		if (sPiece != null)	{
			PieceId = sPiece;
			Piece = new Image("gfx/" + PieceId + ".png", 0, 0, Constants.ChessSquareSize-3, Constants.ChessSquareSize-3);
			Square.add(Piece);
		}
		this.row = row; 
		this.col = col;
		
		initWidget (Square);
	}
}
